package br.com.roteador.component;

import javax.enterprise.context.ApplicationScoped;

import br.com.caelum.vraptor.Convert;
import br.com.caelum.vraptor.converter.Converter;

@Convert(Integer.class)
@ApplicationScoped
public class IntegerConversor implements Converter<Integer> {

	public Integer convert(String string, Class<? extends Integer> arg1) {
		if(!StringUteis.isEmpty(string)){
			string = string.replaceAll("[^0-9]", "");
			return Integer.parseInt(string);
		} else {
			return null;
		}
	}

}